//
//  JYJRecommendCollectionViewCell.m
//  HappyListen
//
//  Created by 冀永金 on 16/8/29.
//  Copyright © 2016年 冀永金. All rights reserved.
//

#import "JYJRecommendCollectionViewCell.h"
#import "BaseLabel.h"
#import "UIImageView+WebCache.h"
#import "Masonry.h"
#import "JYJBestItemsModel.h"
#import "JYJTAMacro.h"
@interface JYJRecommendCollectionViewCell ()
@property (nonatomic, strong) UIImageView *image;
@property (nonatomic, strong) BaseLabel *itemNameLabel;
@property (nonatomic, strong) BaseLabel *itemManagerLabel;
@property (nonatomic, strong) BaseLabel *fromLabel;
@end
@implementation JYJRecommendCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self configSubViews];
    }
    return self;
}
- (void)configSubViews {
    self.image = [[UIImageView alloc]init];
    [self.contentView addSubview:_image];
    self.itemNameLabel = [[BaseLabel alloc]init];
    [self.contentView addSubview:_itemNameLabel];
    _itemNameLabel.textColor = [UIColor whiteColor];
    _itemNameLabel.font = [UIFont systemFontOfSize:20];
    self.fromLabel = [[BaseLabel alloc]init];
    [self.contentView addSubview:_fromLabel];
    self.fromLabel.text = @"From:";
    self.fromLabel.textColor = [UIColor lightGrayColor];
    self.fromLabel.font = [UIFont systemFontOfSize:18];
    self.itemManagerLabel = [[BaseLabel alloc]init];
    [self.contentView addSubview:_itemManagerLabel];
    _itemManagerLabel.textColor = [UIColor lightGrayColor];
    
}
- (void)layoutSubviews {
    [super layoutSubviews];
    [self.image mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView.mas_top).with.offset(0);
        make.left.equalTo(self.contentView.mas_left).with.offset(0);
        make.width.mas_equalTo(self.contentView.bounds.size.width);
        make.height.mas_equalTo(self.contentView.bounds.size.width);
    }];
    [self.itemNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.image.mas_bottom).with.offset(0);
        make.left.equalTo(self.contentView.mas_left).with.offset(0);
        make.width.mas_equalTo(self.contentView.frame.size.width);
        make.height.mas_equalTo(30);
    }];
    [self.fromLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.itemNameLabel.mas_bottom).with.offset(5);
        make.left.equalTo(self.contentView.mas_left).with.offset(0);
        make.width.mas_equalTo(60);
        make.height.mas_equalTo(20);
    }];
    [self.itemManagerLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.itemNameLabel.mas_bottom).with.offset(5);
        make.left.equalTo(self.fromLabel.mas_right).with.offset(0);
        make.width.mas_equalTo(self.contentView.bounds.size.width - 65);
        make.height.mas_equalTo(20);
    }];
    
    
    
}
- (void)setModel:(JYJBestItemsModel *)model {
    _model = model;
    [self.image sd_setImageWithURL:[NSURL URLWithString:model.item_img] placeholderImage:PLACEHOLDERIMAGE];
    self.itemNameLabel.text = model.item_name;
    self.itemManagerLabel.text = model.item_manager;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
